/**
 * 
 */
package bancosys.tec.security.impl.domain;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import jmine.tec.persist.annotation.DiscriminatorComment;
import bancosys.tec.component.Documentation;
import bancosys.tec.persist.authorization.annotation.DisplayName;
import bancosys.tec.security.authorization.Permission;
import bancosys.tec.security.authorization.TaskPermission;

/**
 * @author gigante
 */
@Entity
@DiscriminatorValue("3")
@DiscriminatorComment("TASK")
@DisplayName("Credencial Tarefa")
public class TaskCredential extends Credential {

    private static final int PRIME = 31;

    private static final long serialVersionUID = 509369795790037475L;

    private String taskName;

    private String description;

    /**
     * C'tor vazio
     */
    protected TaskCredential() {
    }

    /**
     * @return the tarefa
     */
    @Column(name = "TASK_NAME")
    @Documentation("NOME DA TAREFA PARA A CREDENCIAL DE TASK.")
    @DisplayName(value = "Tarefa", order = "11")
    public String getTaskName() {
        return this.taskName;
    }

    /**
     * @param tarefa the tarefa to set
     */
    public void setTaskName(String tarefa) {
        this.taskName = tarefa;
    }

    /**
     * @return the descricao
     */
    @Column(name = "TASK_DESCR")
    @DisplayName(value = "Descrição", order = "12")
    @Documentation("DESCRICAO DA TAREFA PARA A CREDENCIAL DE TASK.")
    public String getDescription() {
        return this.description;
    }

    /**
     * @param descricao the descricao to set
     */
    public void setDescription(String descricao) {
        this.description = descricao;
    }

    /**
     * @return o hash code
     */
    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = PRIME * result + (this.taskName == null ? 0 : this.taskName.hashCode());
        return result;
    }

    /**
     * @param obj a outra credencial
     * @return true se as credenciais são iguais, false c.c.
     */
    @Override
    public boolean equals(final Object obj) {
        if (!super.equals(obj)) {
            return false;
        }

        if (this.getClass() != obj.getClass()) {
            return false;
        }
        final TaskCredential other = (TaskCredential) obj;
        if (this.taskName == null) {
            if (other.taskName != null) {
                return false;
            }
        } else if (!this.taskName.equals(other.taskName)) {
            return false;
        }
        return true;
    }

    /**
     * @return {@link TaskPermission}
     */
    @Override
    public Permission createPermission() {
        return new TaskPermission(this.getTaskName());
    }

}
